﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script type="text/javascript">
    var array = [];
    var idsArray = [];
    var father = $.currentSubWindow().frames["Detail"];
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        var data = father.getArrangeData();
        var list = data.split(",");
        for (var index in list) {
            var itemT = list[index].split("|");
            if (itemT.length >= 2) {
                array.push({ TH: itemT[0], MC: itemT[1] });
            } else {
                array.push({ TH: itemT[0], MC: "" });
            }
            idsArray.push(itemT[0]);
        }
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            dataType: 'local',
            height: $(window).height() - 110,
            colModel: [
                { label: '产品编号', name: 'TH', width: 140, align: 'left', sortable: false },
                { label: '产品名称', name: 'MC', width: 240, align: 'left', sortable: false }
            ],
            sortname: 'TH asc',
            viewrecords: true,
            rowNum: 500,
            rownumWidth: 40,
            onSelectRow: function (rowid) {
                //var rowData = $gridList.jqGrid('getRowData', rowid);
                //alert(rowData.TH);
            }
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        for (var i = 0; i < array.length; i++) {
            $gridList.jqGrid('addRowData', i + 1, array[i]);
        }
    }
    function btn_ok() {
        father.$.detailCloseTop();
        father.submitArrange(idsArray);
    }
    function btn_cancel() {
        father.$.detailCloseTop();
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <div style="padding:5px;">
        <table id="gridList"></table>
    </div>
    <div style="text-align:right;padding:5px 30px 5px 0">
        <div class="btn-group" style="">
            <a id="btn_ok" class="btn btn-primary center-block" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 确认</a>
        </div>
        <div class="btn-group" style="margin-left:20px;">
            <a id="btn_cancel" class="btn btn-danger center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 取消</a>
        </div>
    </div>
</div>



